package GreatBattleOfAircraft.obj;

import GreatBattleOfAircraft.Main;
import GreatBattleOfAircraft.utils.GameUtils;

import java.awt.*;

public class BossObj extends GameObj {

    //BossHP
    int bossHp = 20;

    public BossObj(Image img, int x, int y, int width, int height, double speed, Main frame) {
        super(img, x, y, width, height, speed, frame);
    }

    @Override
    public void painSelf(Graphics graphics) {
        super.painSelf(graphics);

        //boss横向移动
        if (x>300||x<0){
           speed = -speed;
        }
        x+=speed;

        if (y<70)
            y += 5;//boss出场


        for (ShellObj shellObj : GameUtils.shellObjList){
            if (this.getRec().intersects(shellObj.getRec())) {
                shellObj.setX(-1000);
                shellObj.setY(-1000);
                GameUtils.removeObjList.add(shellObj);
                bossHp--;
            }
            if (bossHp <= 0)
                Main.state = 4;
        }

        graphics.setColor(Color.white);graphics.fillRect(25,40,500,7);//血条白底
        graphics.setColor(Color.red);graphics.fillRect(27,41,bossHp*496/20,5);//血条
    }

    @Override
    public Rectangle getRec() {
        return super.getRec();
    }
}
